function e(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

var t = require("public/utils/host"), i = e(require("public/utils/user")), n = e(require("public/components/collections")), u = e(require("public/utils/socket")), a = e(require("public/components/withinmsg/record")), o = e(require("utils/config")), r = e(require("utils/util")), l = require("public/utils/request");

require("./public/utils/wx-polyfill"), require("./public/utils/page-enhance"), (0, 
t.rewriteHostAndPrefix)(o.default.host), App({
    globalData: {
        model: o.default.model,
        app: o.default.WX_APP_NAME,
        WX_APP_NAME: o.default.WX_APP_NAME,
        appid: o.default.SITE_APPID,
        environment: "wx",
        version: "2.31.7",
        fromuid: "",
        fromapp: "",
        originSite: {},
        card: {},
        provider: {},
        providerView: {},
        get tokens() {
            return i.default.getTokensSync();
        }
    },
    onLaunch: function(e) {
        var t = this;
        if (this.query = e ? r.default.parseLaunchQueryString(e.query) : {}, wx.getSystemInfoSync) {
            var n = wx.getSystemInfoSync(), s = n.environment, f = n.model, c = o.default.hostV4 + "/user/wechatloginv2", d = o.default.host + "/miniappsuite/user/login", p = s ? d : c;
            this.globalData.environment = s ? "wxwork" : "wx", i.default.api.login = function(e) {
                return (0, l.post)(p, e);
            }, this.globalData.isIniOS = /iPhone|iPad/.test(f);
        }
        i.default.setDefaultParams({
            fromuid: this.query.fromuid,
            app: this.globalData.app,
            appid: this.globalData.appid
        }), wx.getExtConfig && wx.getExtConfig({
            success: function(e) {
                var i = e.extConfig;
                if (!r.default.isEmptyObject(i)) {
                    var n = i.ext.attr, u = n.sid, a = n.version;
                    t.globalData.sid = u, t.globalData.version = a;
                }
            }
        }), u.default.on(u.default.EVENT_TYPES.MESSAGE_CHAT, function(e) {
            var t = e.params;
            a.default.load(t);
        });
    },
    onShow: function() {
        var e = this;
        i.default.getTokens().then(function(t) {
            e.initSocket(t.accesstoken);
        });
    },
    onHide: function() {
        r.default.updateViewSiteStatus(), wx.removeStorageSync("isReadInit"), wx.removeStorageSync("viewSiteList");
    },
    initSocket: function(e) {
        u.default.connect(e);
    },
    getTokens: i.default.getTokens.bind(i.default),
    component: n.default
});